import Api from './api'

/**
 * 工厂接口
 */
class FactoryApi extends Api {
  /**
   * 获取工厂信息
   */
  getFactory () {
    return this.request({
      url: `${this.servicePath}/${this.modulePath}`,
      method: 'get'
    })
  }

  /**
   * 更新工厂信息
   * @param {*} factory 工厂
   */
  updateFactory (factory) {
    return this.request({
      url: `${this.servicePath}/${this.modulePath}`,
      method: 'put',
      data: factory
    })
  }

  /**
   * 更新工厂支付密码
   * @param {*} password 登录密码
   * @param {*} oldConfirmPassword 原支付密码
   * @param {*} newConfirmPassword 新支付密码
   */
  updateConfirmPassword (password, oldConfirmPassword, newConfirmPassword) {
    return this.request({
      url: `${this.servicePath}/${this.modulePath}/confirmPassword`,
      method: 'put',
      data: {
        password: password,
        oldConfirmPassword: oldConfirmPassword,
        newConfirmPassword: newConfirmPassword
      },
      showLoading: false
    })
  }

  getSubFactorys () {
    return this.request({
      url: `${this.servicePath}/${this.modulePath}/sub`,
      method: 'get'
    })
  }
}

export default new FactoryApi('factory/factory')
